package edu.pku.sei.act.main.provider;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.TreeViewer;

import edu.pku.sei.act.main.action.ArchiModelerOpenDiagramAction;
import edu.pku.sei.act.main.action.ArchiModelerExplorerActionGroup;
import edu.pku.sei.act.main.action.ArchiModelerOpenPackageDiagramAction;
import edu.pku.sei.act.main.action.ArchiModelerOpenTaskDiagramAction;
import edu.pku.sei.act.main.project.ArchiModelerProject;
import edu.pku.sei.act.model.common.ArchiModelConst;
import edu.pku.sei.act.model.mote.MoteForPackage;
import edu.pku.sei.gmp.explorer.actions.GMPExplorerActionGroup;
import edu.pku.sei.gmp.explorer.actions.IExplorerActionProvider;
import edu.pku.sei.gmp.model.shape.GMPDiagram;

public class ArchiModelerExplorerActionProvider implements
       IExplorerActionProvider{

	@Override
	public GMPExplorerActionGroup getActionGroup(TreeViewer tv) {

		return new ArchiModelerExplorerActionGroup(tv);
	}

	@Override
	public Action getDoubleClickAction(Object selectedElement) {
		if (selectedElement instanceof GMPDiagram) {
			String diagramType = ((GMPDiagram) selectedElement).getType();
			if (diagramType.equals(ArchiModelConst.__ARCHIMODELDIAGRAM__)){
				return new ArchiModelerOpenDiagramAction(selectedElement);
			}else if(diagramType.equals(ArchiModelConst.__ARCHIMODELPACKAGEDIAGRAM__)){
				return new ArchiModelerOpenPackageDiagramAction(selectedElement);
			}else if(diagramType.equals(ArchiModelConst.__ARCHIMODELTASKDIAGRAM__)){
				return new ArchiModelerOpenTaskDiagramAction(selectedElement);
			}
		}else if(selectedElement instanceof MoteForPackage){
			
			//return new ArchiModelerOpenDiagramAction(selectedElement);
			
		}
		return null;
	}

	@Override
	public String getProjectNature() {
		
		return ArchiModelerProject.PROJECT_NATURE;
		
	}

}
